class Solution {
public:
    int singleNonDuplicate(vector<int>& nums) {
        int i = 0;
        int temp;
        while(i < nums.size()-1)
        {
            temp = nums[i];
            if(temp != nums[i + 1])
                return temp;
            do{i++;} while(nums[i] == temp);
        }
        return nums[nums.size() - 1];
    }
};
